package map_;

import java.util.Properties;

/**
 * @Author 小闽
 * @Date 2024/11/14 11:25
 * @PackageName: map_
 * @ClassName: Properties
 * @Description:
 * @Version
 */
@SuppressWarnings({"all"})
public class Properties_ {
    public static void main(String[] args) {
        // 1. Properties 继承 Hashtable
        // 2. 可以通过k-v存放数据，当然key和value不能为null
        // 增加
        Properties properties = new Properties();
//        properties.put(null,"abc"); 抛出空指针异常
//        properties.put("abc",null); 抛出空指针异常
        properties.put("john",100); // k-v
        properties.put("lucy",100);
        properties.put("lic",100);
        properties.put("lic",88); // 如果有相同的key,value被替换

        System.out.println("properties=" + properties);

        // 通过k获取对应的值
        System.out.println(properties.get("lic")); // 88
        // 删除
        properties.remove("lic");
        System.out.println("properties=" + properties);

        // 修改
        properties.put("john","约翰");
        System.out.println("properties=" + properties);
    }
}
